
/*****************************************************************************/
/* @file     Demo.c
 * @author   TEST TEAM     
 * @version  v0
 * @date     Septemper 2022
 * @brief    Simple function in C, Ansi-style

 * Copyright (C) 2022 Hangzhou SDIC Microelectronics Co., Ltd*/

/******************************************************************************/
/**
 * @brief the main entry of the application; when run to here, the system has been initialized includes:
 * 1 CPU processor status register
 * 2 CPU vector base register
 * 3 CPU Units such as MGU, Cache...
 * 4 IO base address
 *
 * @return For MCU application, it's better to loop here
 */

#include "define.h"
/*---------------------------------------------------
 * 函数功能：FLASH测试Demo
 * 入口参数：None
 * 出口参数：None
 * 返回值  ：None
 * 编写日期：
 * 作者    ：
 *-------------------------------------------------*/
void  FLASH_Opration_Demo(void)
{
/*
	RCC_LoadIHRCALValue();  		//载入IHRC的校准值(若要操作flash，IHRC必须要校准) 
	FLASH_OB_DEFAULT();     		//将选项字节恢复出厂设置	
	FLASH_OB_RDPConfig(FLASH_OB_RDP_Level_0);					//将读保护等级写为0
	//FLASH_OB_UserConfig(OB_User_STOP_NoRST|OB_User_DOZE_NoRST); //配置执行低功耗指令（DOZE,STOP)是否产生复位
	FLASH_OB_EnableWRP(FLASH_WRP_Block29);  					//使能FLASH写保护
	FLASH_OB_EnableWRP(FLASH_WRP_Block28);  					//使能FLASH写保护
	FLASH_OB_EnableWRP(FLASH_WRP_Block27|FLASH_WRP_Block26);  	//使能FLASH写保护
	FLASH_OB_EnableWRP(FLASH_WRP_Block22);  					//使能FLASH写保护
	FLASH_OB_EnableWRP(FLASH_WRP_Block21|FLASH_WRP_Block20);  	//使能FLASH写保护
	FLASH_OB_EnableWRP(FLASH_WRP_AllBlock);  					//使能FLASH写保护
	FLASH_OB_DEFAULT();    										//将选项字节恢复出厂设置
*/	
}
	
/*---------------------------------------------------
 * 函数功能：UART测试Demo
 * 入口参数：None
 * 出口参数：None
 * 返回值  ：None
 * 编写日期：
 * 作者    ：
 *-------------------------------------------------*/
int  UART_Application_Demo(void)
{	
	UART_InitTypeDef  UART_InitStruct;
	VIC_InitTypeDef VIC_InitType;
//	Initialization();//初始化

	RCC_APB2PeriphClockConfig(RCC_APBPeriph_UART0,RCC_UARTCLK_SYSCLK,0);//UART0时钟源选择SYSCLK
	RCC_APBPeriphClockCmd(RCC_APBPeriph_UART0, ENABLE);//UART0时钟使能
   
    //UART0配置
	UART_InitStruct.UART_BaudRate=115200; //通讯波特率115200
	UART_InitStruct.UART_Mode=UART_Mode_TRx;//工作在全双工
	UART_InitStruct.UART_Parity=UART_Parity_None;//禁止校验
	UART_InitStruct.UART_StopBits=UART_StopBits_1;//1个停止位
	UART_InitStruct.UART_WordLength=UART_WordLength_8b;//数据长度8位
	UART_InitStruct.UART_CarryWave=UART_CarryWave_None; //关闭载波功能
	UART_Init(UART0,&UART_InitStruct);
   
	UART_ClearFlagStatus(UART0, UART_Flag_RXNE); //清接收完成标志位
	UART_ITConfig(UART0, UART_IT_RXNEIE, ENABLE);//允许产生接收中断
   
	UART_Cmd(UART0,ENABLE);//UART0使能
	
	

	//UART0接收中断初始化
	VIC_InitType.VIC_IRQChannel=UART0_IRQn;//选择UART0中断源
	VIC_InitType.VIC_IRQChannelCmd=ENABLE;//使能对应编号的中断通道
	VIC_InitType.VIC_IRQChannelPriority=VIC_IRQChannelPriority0;//配置对应中断向量的优先级
	VIC_InitType.VIC_IRQChannelWakeUpLowPowerCmd=DISABLE;//使能对应中断向量可唤醒低功耗模式
	VIC_InitType.VIC_PrioThreshold=VIC_PrioThreshold0;//配置对应中断向量优先级的比较阈值
	VIC_InitType.VIC_PrioThresholdCmd=DISABLE;//使能优先级阈值比较功能
	VIC_Init(&VIC_InitType);
	
	
	while(1)
	{
		
		while(UART_GetFlagStatus(UART0,UART_Flag_TXE)== 0);//等待发送完成标志位置1
		UART_SendData(UART0,0x11);//向串口发送0X11
		while(UART_GetFlagStatus(UART0,UART_Flag_TXE)== 0);
		UART_SendData(UART0,0x22);//向串口发送0X22
		while(UART_GetFlagStatus(UART0,UART_Flag_TXE)== 0);
		UART_SendData(UART0,0x33);//向串口发送0X33
		while(UART_GetFlagStatus(UART0,UART_Flag_TXE)== 0);
		UART_SendData(UART0,0x44);//向串口发送0X44
		
	}
	
}
